package com.example.demo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;

/**
 * @author Shanks
 * @date 2020-10-27
 */
@Data
@ApiModel(value = "DateVO", description = "日期")
public class DateVO {

    @ApiModelProperty(value = "姓名", example = "Shanks")
    private String name;

    /**
     * 入参的数据绑定, 需要使用@JsonFormat
     */
    @ApiModelProperty(value = "生日", example = "2020-10-27 16:01:14")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date birthday;

    @ApiModelProperty(value = "日期, 格式为: yyyy-MM-dd", example = "2020-10-27")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date date;

    @ApiModelProperty(value = "日期, 格式为: yyyy/MM/dd", example = "2020/10/27")
    @DateTimeFormat(pattern = "yyyy/MM/dd")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd", timezone = "GMT+8")
    private Date date2;

    @ApiModelProperty(value = "日期, 格式为: yyyyMMdd", example = "20201027")
    @DateTimeFormat(pattern = "yyyyMMdd")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyyMMdd", timezone = "GMT+8")
    private Date date3;

    @ApiModelProperty(value = "日期, 格式为: yyyy/MM/dd HH:mm", example = "2020/10/29 09:42")
    @DateTimeFormat(pattern = "yyyy/MM/dd HH:mm")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy/MM/dd HH:mm", timezone = "GMT+8")
    private Date date4;
}